from rest_framework import serializers
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory


#1, channel序列化器
class ChannelSerializers(serializers.ModelSerializer):

    # 1,重写group,category,group_id,category_id
    group = serializers.StringRelatedField(read_only=True)
    category = serializers.StringRelatedField(read_only=True)
    group_id = serializers.CharField()
    category_id = serializers.CharField()

    class Meta:
        model = GoodsChannel
        fields = "__all__"

class ChannelCategorySerializers(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields = ["id", "name"]

class ChannelTypeSerializers(serializers.ModelSerializer):
    class Meta:
        model = GoodsChannelGroup
        fields = ["id", "name"]